<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<!doctype html>
<html lang="zh">
	<style>
		 /* 完整样式 */
		 .pagination {
            display: flex;
            gap: 5px;
            flex-wrap: wrap;
            justify-content: center;
        }

        .page-item {
            list-style: none;
        }

        .page-link {
            padding: 8px 16px;
            border: 1px solid #e0e0e0;
            border-radius: 4px;
            background: #ffffff;
            color: #1a237e;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 6px;
            font-family: 'Segoe UI', system-ui;
            font-size: 14px;
        }

        .page-link:hover:not(:disabled) {
            background: #f5f5f5;
            transform: translateY(-1px);
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }

        .page-link:disabled {
            background: #f8f9fa;
            color: #6c757d;
            cursor: not-allowed;
            opacity: 0.7;
        }

        .page-item.active .page-link {
            background: #1a237e;
            border-color: #1a237e;
            color: white !important;
        }

        .page-first {
            background: #e3f2fd !important;
            border-color: #90caf9 !important;
        }

        .page-last {
            background: #f3e5f5 !important;
            border-color: #ce93d8 !important;
        }

        .fas {
            font-size: 14px;
        }

	</style>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<meta name="description" content="通辽航空管理平台 ">
		<title>通辽航空管理平台 </title>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<link rel="stylesheet" href="fonts/style.css">
		<link rel="stylesheet" href="css/main.css">
		<link rel="stylesheet" href="css/css.css">
	</head>
	<body>
		<header class="header">
			<div class="container-fluid">
				<div class="row gutters">
					<div class="col-xl-4 col-lg-4 col-md-4 col-sm-4 col-9">
						<a href="admin_index.jsp" class="logo"> <img src="img/logo.png">通辽航空管理平台  </a>
					</div>
					<div class="col-xl-8 col-lg-8 col-md-8 col-sm-8 col-3">
						<ul class="header-actions">
						
							<li class="dropdown">
								<a href="#" id="userSettings" class="user-settings" data-toggle="dropdown" aria-haspopup="true">
									<span class="user-name">管理员</span>
									<span class="avatar">NR<span class="status busy"></span></span>
								</a>
								<div class="dropdown-menu dropdown-menu-right" aria-labelledby="userSettings">
									<div class="header-profile-actions">
										
										<a href="hospital-add-doctor.html"><i class="icon-user1"></i> My Profile</a>
										<a href="account-settings.html"><i class="icon-settings1"></i> Account Settings</a>
										<a href="hospital-reviews.html"><i class="icon-activity"></i> Activity Logs</a>
										<a href="login.html"><i class="icon-log-out1"></i> Sign Out</a>
									</div>
								</div>
							</li>
						</ul>						
					</div>
				</div>
			</div>
		</header>
		<div class="container-fluid">


			<!-- Navigation start -->
			<nav class="navbar navbar-expand-lg custom-navbar">
				<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#royalHospitalsNavbar" aria-controls="royalHospitalsNavbar" aria-expanded="false" aria-label="Toggle navigation">
					<span class="navbar-toggler-icon">
						<i></i>
						<i></i>
						<i></i>
					</span>
				</button>
				<div class="collapse navbar-collapse" id="royalHospitalsNavbar">
					<ul class="navbar-nav">
						<li class="nav-item">
							<a class="nav-link " href="FlightsServlet?pageNo=1">
								<i class="icon-home nav-icon"></i>
								首页</a>
						</li>
						<li class="nav-item dropdown">
							<a class="nav-link dropdown-toggle" href="#" id="doctoRs" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="icon-person_pin nav-icon"></i>
								数据录入
							</a>
							<ul class="dropdown-menu" aria-labelledby="doctoRs">
								<li><a class="dropdown-item" href="flight_insert.jsp">录入航班</a></li>
								<li><a class="dropdown-item" href="aircraft_insert.jsp">录入飞机</a></li>
							</ul>
						</li>
					
						<li class="nav-item dropdown">
							<a class="nav-link dropdown-toggle " href="#" id="formsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="icon-assignment_turned_in nav-icon"></i>
								申请管理
							</a>
							<ul class="dropdown-menu" aria-labelledby="formsDropdown">
								<li><a class="dropdown-item " href="QuitsServlet?pageNo=1">退票申请列表</a></li>
								<li><a class="dropdown-item " href="AuditsServlet?pageNo=1">改签申请列表</a></li>
							</ul>
						</li>
						<li class="nav-item dropdown">
							<a class="nav-link dropdown-toggle " href="#" id="uiElementsDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="icon-assignment nav-icon"></i>
								数据管理
							</a>
							<ul class="dropdown-menu" aria-labelledby="uiElementsDropdown">
								<li><a class="dropdown-item" href="${pageContext.request.contextPath}/UserList?pageNo=1">用户数据管理</a></li>
								<li><a class="dropdown-item" href="${pageContext.request.contextPath}/AircraftListServlet?pageNo=1">飞机数据管理</a></li>

							</ul>
						</li>
						<li class="nav-item dropdown">
							<a class="nav-link dropdown-toggle active-page" href="#" id="loginDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<i class="icon-burst_mode nav-icon"></i>
								注册申请 
							</a>
							<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="loginDropdown">
								<li><a class="dropdown-item active-page" href="RegisterListServlet?pageNo=1">用户注册申请</a></li>
							</ul>
						</li>
					
					</ul>
				</div>
			</nav>
		
			

			<div class="main-container">
				<div class="page-header">
					<ol class="breadcrumb">
						<li class="breadcrumb-item">注册申请</li>
						<li class="breadcrumb-item active">用户注册审核</li>
					</ol>
				</div>
				<div class="content-wrapper">
					<div class="card-body">
						<form id="batchForm" action="RegisterProcessServlet" method="post">
							<div class="table-responsive">
								<table class="table table-hover table-bordered">
									<thead class="thead-light">
										<tr>
											<th><input type="checkbox" class="allsel" onclick="selectAll(this)"></th>
											<th>申请ID</th>
											<th>用户照片</th>
											<th>姓名</th>
											<th>手机号码</th>
											<th>身份证号</th>
											<th>操作</th>
										</tr>
									</thead>
									<tbody>
										<c:forEach items="${list}" var="reg">
											<tr>
												<td>
													<input type="hidden" name="registerId" value="${reg.register_id}">
													<input type="checkbox" name="registerIds" value="${reg.register_id}">
												</td>
												<td>${reg.register_id}</td>
												<td>
													<c:if test="${not empty reg.user.uimage}">
														<img class="roundimg" src="${pageContext.request.contextPath}/DisplayImageServlet?src=${reg.user.uimage}" 
															 width="50" alt="用户照片"
															 onerror="this.src='${pageContext.request.contextPath}/DisplayImageServlet?src=/upload/default_avatar.png'">
													</c:if>
												</td>
												<td>${reg.user.name}</td>
												<td>${reg.user.phone}</td>
												<td>${reg.user.identityCard}</td>
												<td>
													<a href="RegisterDetailServlet?id=${reg.register_id}" class="btn btn-sm btn-info">通过</a>
												</td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
							
							<div class="row mt-3">
								<div class="col-md-4">
									<button type="button" class="btn btn-success" onclick="batchProcess('approve')">批量通过</button>
									<button type="button" class="btn btn-danger" onclick="batchProcess('reject')">批量拒绝</button>
								</div>
							<input type="hidden" name="action" id="action">
						</form>

						<%-- 页码显示 --%>
						<nav aria-label="Page navigation" class="page">
							<ul class="pagination">
								<%-- 上一页 --%>
								<li class="page-item ${box.pageNo == 1 ? 'disabled' : ''}">
									<a class="page-link"
									   href="${box.pageNo > 1 ? pageContext.request.contextPath.concat('/RegisterListServlet?pageNo=').concat(box.pageNo-1) : 'javascript:;'}"
									   aria-label="Previous">
										<span aria-hidden="true">上一页</span>
									</a>
								</li>

								<%-- 计算页码范围 --%>
								<c:set var="totalPages" value="${box.getBottomPageNo()}" />
								<c:set var="startPage" value="${box.pageNo - 2}" />
								<c:set var="endPage" value="${box.pageNo + 2}" />

								<%-- 修正范围 --%>
								<c:choose>
									<c:when test="${startPage < 1}">
										<c:set var="endPage" value="${endPage + (1 - startPage)}" />
										<c:set var="startPage" value="1" />
									</c:when>
									<c:when test="${endPage > totalPages}">
										<c:set var="startPage" value="${startPage - (endPage - totalPages)}" />
										<c:set var="endPage" value="${totalPages}" />
									</c:when>
								</c:choose>
								<c:set var="startPage" value="${startPage < 1 ? 1 : startPage}" />
								<c:set var="endPage" value="${endPage > totalPages ? totalPages : endPage}" />

								<%-- 首部省略号 --%>
								<c:if test="${startPage > 1}">
									<li class="page-item">
										<a class="page-link" href="${pageContext.request.contextPath}/RegisterListServlet?pageNo=1">1</a>
									</li>
									<c:if test="${startPage > 2}">
										<li class="page-item disabled">
											<span class="page-link">...</span>
										</li>
									</c:if>
								</c:if>

								<%-- 核心页码 --%>
								<c:forEach begin="${startPage}" end="${endPage}" varStatus="i">
									<li class="page-item ${i.index == box.pageNo ? 'active' : ''}">
										<a class="page-link"
										   href="${pageContext.request.contextPath}/RegisterListServlet?pageNo=${i.index}">
											${i.index}
										</a>
									</li>
								</c:forEach>

								<%-- 尾部省略号 --%>
								<c:if test="${endPage < totalPages}">
									<c:if test="${endPage < totalPages - 1}">
										<li class="page-item disabled">
											<span class="page-link">...</span>
										</li>
									</c:if>
									<li class="page-item">
										<a class="page-link"
										   href="${pageContext.request.contextPath}/RegisterListServlet?pageNo=${totalPages}">
											${totalPages}
										</a>
									</li>
								</c:if>

								<%-- 下一页 --%>
								<li class="page-item ${box.pageNo == totalPages ? 'disabled' : ''}">
									<a class="page-link"
									   href="${box.pageNo < totalPages ? pageContext.request.contextPath.concat('/RegisterListServlet?pageNo=').concat(box.pageNo+1) : 'javascript:;'}"
									   aria-label="Next">
										<span aria-hidden="true">下一页</span>
									</a>
								</li>
							</ul>
						</nav>
					</div>
				</div>
			</div>

			<footer class="main-footer"> 2025 © Copyright by <a href="https://www.bootstrapmb.com">bootstrapMB</a>-通辽航空管理平台 © 2025-2030</footer>

		</div>
		
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.bundle.min.js"></script>
		<script src="js/moment.js"></script>

		<script src="laydate/laydate.js" type="text/javascript"></script> 
		<script>
		lay('#version').html('-v'+ laydate.v);
		laydate.render({
			elem: '#date'
		 ,range: true
		  ,theme: '#13a98c'
		});
		</script>

		<script>
			function selectAll(source) {
				const checkboxes = document.getElementsByName('registerIds');
				for(let checkbox of checkboxes) {
					checkbox.checked = source.checked;
				}
			}

			function batchProcess(action) {
				if(confirm('确定要执行此操作吗？')) {
					document.getElementById('action').value = action;
					document.getElementById('batchForm').submit();
				}
			}
		</script>
		
	</body>
</html>